{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Importing libraries\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import re"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import lightgbm as lgb\n",
    "import xgboost as xgb\n",
    "from sklearn.metrics import mean_squared_error\n",
    "from sklearn.model_selection import KFold\n",
    "from catboost import CatBoostRegressor "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Reading train and test data\n",
    "df = pd.read_csv(r'C:\\MachineHack\\Participant_Data_Tea_Story\\train.csv')\n",
    "test = pd.read_csv(r'C:\\MachineHack\\Participant_Data_Tea_Story\\test.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Train set shape (544, 16)\n",
      "Test set shape (29, 16)\n"
     ]
    }
   ],
   "source": [
    "print(f\"Train set shape {df.shape}\")\n",
    "print(f\"Test set shape {test.shape}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EDA, Preprocessing and Feature Engineering"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>WeekEnding_Date</th>\n",
       "      <th>Kolkata_Average_Price</th>\n",
       "      <th>Kolkata_Ref_Price</th>\n",
       "      <th>Bangalore_Average_Price</th>\n",
       "      <th>Bangalore_Ref_Price</th>\n",
       "      <th>Cochin_Average_Price</th>\n",
       "      <th>Cochin_Ref_Price</th>\n",
       "      <th>Darjeeling_Average_Price</th>\n",
       "      <th>Darjeeling_Ref_Price</th>\n",
       "      <th>Ernakulam_Average_Price</th>\n",
       "      <th>Ernakulam_Ref_Price</th>\n",
       "      <th>Siliguri_Average_Price</th>\n",
       "      <th>Siliguri_Ref_Price</th>\n",
       "      <th>Guwahati_Average_Price</th>\n",
       "      <th>Guwahati_Ref_Price</th>\n",
       "      <th>Average</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>03/01/09</td>\n",
       "      <td>99.01</td>\n",
       "      <td>79.79</td>\n",
       "      <td>N.S.</td>\n",
       "      <td>76.19</td>\n",
       "      <td>84.02</td>\n",
       "      <td>70.07</td>\n",
       "      <td>81.66</td>\n",
       "      <td>57.83</td>\n",
       "      <td>68.94</td>\n",
       "      <td>51.67</td>\n",
       "      <td>70.74</td>\n",
       "      <td>53.88</td>\n",
       "      <td>65.55</td>\n",
       "      <td>46.75</td>\n",
       "      <td>69.700000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10/01/09</td>\n",
       "      <td>97.74</td>\n",
       "      <td>78.73</td>\n",
       "      <td>87.48</td>\n",
       "      <td>73.97</td>\n",
       "      <td>82.72</td>\n",
       "      <td>68.17</td>\n",
       "      <td>83.31</td>\n",
       "      <td>58.02</td>\n",
       "      <td>67.24</td>\n",
       "      <td>52.23</td>\n",
       "      <td>70.47</td>\n",
       "      <td>53.39</td>\n",
       "      <td>67.39</td>\n",
       "      <td>46.84</td>\n",
       "      <td>70.550000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>17/01/09</td>\n",
       "      <td>95.95</td>\n",
       "      <td>71.01</td>\n",
       "      <td>87.66</td>\n",
       "      <td>71.01</td>\n",
       "      <td>80.58</td>\n",
       "      <td>67.16</td>\n",
       "      <td>82.25</td>\n",
       "      <td>57.49</td>\n",
       "      <td>69.64</td>\n",
       "      <td>52.48</td>\n",
       "      <td>71.66</td>\n",
       "      <td>53.18</td>\n",
       "      <td>69.51</td>\n",
       "      <td>48.04</td>\n",
       "      <td>69.830000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>24/01/09</td>\n",
       "      <td>94.14</td>\n",
       "      <td>73.38</td>\n",
       "      <td>85.69</td>\n",
       "      <td>65.66</td>\n",
       "      <td>N.S.</td>\n",
       "      <td>65.57</td>\n",
       "      <td>80.87</td>\n",
       "      <td>54.59</td>\n",
       "      <td>N.S.</td>\n",
       "      <td>53.43</td>\n",
       "      <td>71.12</td>\n",
       "      <td>52.07</td>\n",
       "      <td>69.14</td>\n",
       "      <td>48.5</td>\n",
       "      <td>67.846667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>31/01/09</td>\n",
       "      <td>91.45</td>\n",
       "      <td>70.39</td>\n",
       "      <td>N.S.</td>\n",
       "      <td>64.99</td>\n",
       "      <td>79.27</td>\n",
       "      <td>62.09</td>\n",
       "      <td>80.76</td>\n",
       "      <td>57.06</td>\n",
       "      <td>69.65</td>\n",
       "      <td>53.38</td>\n",
       "      <td>72.3</td>\n",
       "      <td>52.5</td>\n",
       "      <td>69.39</td>\n",
       "      <td>50.33</td>\n",
       "      <td>67.196923</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  WeekEnding_Date Kolkata_Average_Price Kolkata_Ref_Price  \\\n",
       "0        03/01/09                 99.01             79.79   \n",
       "1        10/01/09                 97.74             78.73   \n",
       "2        17/01/09                 95.95             71.01   \n",
       "3        24/01/09                 94.14             73.38   \n",
       "4        31/01/09                 91.45             70.39   \n",
       "\n",
       "  Bangalore_Average_Price Bangalore_Ref_Price Cochin_Average_Price  \\\n",
       "0                    N.S.               76.19                84.02   \n",
       "1                   87.48               73.97                82.72   \n",
       "2                   87.66               71.01                80.58   \n",
       "3                   85.69               65.66                 N.S.   \n",
       "4                    N.S.               64.99                79.27   \n",
       "\n",
       "  Cochin_Ref_Price Darjeeling_Average_Price Darjeeling_Ref_Price  \\\n",
       "0            70.07                    81.66                57.83   \n",
       "1            68.17                    83.31                58.02   \n",
       "2            67.16                    82.25                57.49   \n",
       "3            65.57                    80.87                54.59   \n",
       "4            62.09                    80.76                57.06   \n",
       "\n",
       "  Ernakulam_Average_Price Ernakulam_Ref_Price Siliguri_Average_Price  \\\n",
       "0                   68.94               51.67                  70.74   \n",
       "1                   67.24               52.23                  70.47   \n",
       "2                   69.64               52.48                  71.66   \n",
       "3                    N.S.               53.43                  71.12   \n",
       "4                   69.65               53.38                   72.3   \n",
       "\n",
       "  Siliguri_Ref_Price Guwahati_Average_Price Guwahati_Ref_Price    Average  \n",
       "0              53.88                  65.55              46.75  69.700000  \n",
       "1              53.39                  67.39              46.84  70.550000  \n",
       "2              53.18                  69.51              48.04  69.830000  \n",
       "3              52.07                  69.14               48.5  67.846667  \n",
       "4               52.5                  69.39              50.33  67.196923  "
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "WeekEnding_Date             0\n",
       "Kolkata_Average_Price       0\n",
       "Kolkata_Ref_Price           2\n",
       "Bangalore_Average_Price     0\n",
       "Bangalore_Ref_Price         2\n",
       "Cochin_Average_Price        0\n",
       "Cochin_Ref_Price            3\n",
       "Darjeeling_Average_Price    0\n",
       "Darjeeling_Ref_Price        2\n",
       "Ernakulam_Average_Price     0\n",
       "Ernakulam_Ref_Price         1\n",
       "Siliguri_Average_Price      1\n",
       "Siliguri_Ref_Price          1\n",
       "Guwahati_Average_Price      0\n",
       "Guwahati_Ref_Price          0\n",
       "Average                     0\n",
       "dtype: int64"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Checking for null values\n",
    "df.isnull().sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 544 entries, 0 to 543\n",
      "Data columns (total 16 columns):\n",
      " #   Column                    Non-Null Count  Dtype  \n",
      "---  ------                    --------------  -----  \n",
      " 0   WeekEnding_Date           544 non-null    object \n",
      " 1   Kolkata_Average_Price     544 non-null    object \n",
      " 2   Kolkata_Ref_Price         542 non-null    object \n",
      " 3   Bangalore_Average_Price   544 non-null    object \n",
      " 4   Bangalore_Ref_Price       542 non-null    object \n",
      " 5   Cochin_Average_Price      544 non-null    object \n",
      " 6   Cochin_Ref_Price          541 non-null    object \n",
      " 7   Darjeeling_Average_Price  544 non-null    object \n",
      " 8   Darjeeling_Ref_Price      542 non-null    object \n",
      " 9   Ernakulam_Average_Price   544 non-null    object \n",
      " 10  Ernakulam_Ref_Price       543 non-null    object \n",
      " 11  Siliguri_Average_Price    543 non-null    object \n",
      " 12  Siliguri_Ref_Price        543 non-null    object \n",
      " 13  Guwahati_Average_Price    544 non-null    object \n",
      " 14  Guwahati_Ref_Price        544 non-null    object \n",
      " 15  Average                   544 non-null    float64\n",
      "dtypes: float64(1), object(15)\n",
      "memory usage: 68.1+ KB\n"
     ]
    }
   ],
   "source": [
    "df.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Converting date to datetime and extracting weekday feature\n",
    "df['weekday'] = pd.to_datetime(df['WeekEnding_Date']).dt.weekday\n",
    "\n",
    "test['weekday'] = pd.to_datetime(test['WeekEnding_Date']).dt.weekday"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Setting date as index\n",
    "df.set_index('WeekEnding_Date', inplace=True)\n",
    "test.set_index('WeekEnding_Date', inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "# All numerical columns except target column \n",
    "cols = [i for i in df.columns if i not in ['Average']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 'avg' feature which is the average of all other independent columns\n",
    "def avg(cols, df):\n",
    "    df['avg'] = 0\n",
    "    for col in cols:\n",
    "        df['avg'] += df[col].astype('float')\n",
    "    df['avg'] /= len(cols)\n",
    "    return df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Using regex to remove texts like 'No sale', 'No. Sale', 'N. S.' etc.\n",
    "def remove_text(text):\n",
    "    no_text = re.sub('[^0-9.]', '', text)\n",
    "    return no_text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Removing text and filling the NaN values using forward and backward filling technique\n",
    "for i in cols:\n",
    "    df[i] = df[i].apply(lambda x: remove_text(str(x)))\n",
    "    df[i] = df[i].apply(lambda x: np.nan if x in ['..', '', '.'] else x)\n",
    "    df[i] = df[i].astype('float')\n",
    "    df[i].fillna(method='ffill', inplace=True)\n",
    "    df[i].fillna(method='bfill', inplace=True)\n",
    "    \n",
    "    \n",
    "for i in cols:\n",
    "    test[i] = test[i].apply(lambda x: remove_text(str(x)))\n",
    "    test[i] = test[i].apply(lambda x: np.nan if x in ['..', '', '.'] else x)\n",
    "    test[i] = test[i].astype('float')   \n",
    "    test[i].fillna(method='ffill', inplace=True)\n",
    "    test[i].fillna(method='bfill', inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Calling 'avg' function to create average feature\n",
    "df = avg(cols, df)\n",
    "test = avg(cols, test)\n",
    "\n",
    "\n",
    "test.drop('Average', axis=1, inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Kolkata_Average_Price</th>\n",
       "      <th>Kolkata_Ref_Price</th>\n",
       "      <th>Bangalore_Average_Price</th>\n",
       "      <th>Bangalore_Ref_Price</th>\n",
       "      <th>Cochin_Average_Price</th>\n",
       "      <th>Cochin_Ref_Price</th>\n",
       "      <th>Darjeeling_Average_Price</th>\n",
       "      <th>Darjeeling_Ref_Price</th>\n",
       "      <th>Ernakulam_Average_Price</th>\n",
       "      <th>Ernakulam_Ref_Price</th>\n",
       "      <th>Siliguri_Average_Price</th>\n",
       "      <th>Siliguri_Ref_Price</th>\n",
       "      <th>Guwahati_Average_Price</th>\n",
       "      <th>Guwahati_Ref_Price</th>\n",
       "      <th>Average</th>\n",
       "      <th>weekday</th>\n",
       "      <th>avg</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>544.000000</td>\n",
       "      <td>544.000000</td>\n",
       "      <td>544.000000</td>\n",
       "      <td>544.000000</td>\n",
       "      <td>544.000000</td>\n",
       "      <td>544.000000</td>\n",
       "      <td>544.000000</td>\n",
       "      <td>544.000000</td>\n",
       "      <td>544.000000</td>\n",
       "      <td>544.000000</td>\n",
       "      <td>544.000000</td>\n",
       "      <td>544.000000</td>\n",
       "      <td>544.000000</td>\n",
       "      <td>544.000000</td>\n",
       "      <td>544.000000</td>\n",
       "      <td>544.000000</td>\n",
       "      <td>544.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>137.254890</td>\n",
       "      <td>131.644467</td>\n",
       "      <td>127.478327</td>\n",
       "      <td>121.630588</td>\n",
       "      <td>119.128640</td>\n",
       "      <td>113.863640</td>\n",
       "      <td>100.817463</td>\n",
       "      <td>95.589173</td>\n",
       "      <td>79.787224</td>\n",
       "      <td>76.863364</td>\n",
       "      <td>84.819449</td>\n",
       "      <td>80.965404</td>\n",
       "      <td>71.446562</td>\n",
       "      <td>69.312445</td>\n",
       "      <td>100.660317</td>\n",
       "      <td>4.270221</td>\n",
       "      <td>94.324790</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>23.646185</td>\n",
       "      <td>26.102421</td>\n",
       "      <td>23.124376</td>\n",
       "      <td>25.361527</td>\n",
       "      <td>19.036986</td>\n",
       "      <td>20.637354</td>\n",
       "      <td>16.669939</td>\n",
       "      <td>18.052455</td>\n",
       "      <td>14.671259</td>\n",
       "      <td>14.324043</td>\n",
       "      <td>15.564106</td>\n",
       "      <td>15.003531</td>\n",
       "      <td>14.766510</td>\n",
       "      <td>14.153677</td>\n",
       "      <td>13.711767</td>\n",
       "      <td>1.546860</td>\n",
       "      <td>12.374570</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>67.640000</td>\n",
       "      <td>64.790000</td>\n",
       "      <td>66.400000</td>\n",
       "      <td>55.650000</td>\n",
       "      <td>71.290000</td>\n",
       "      <td>57.020000</td>\n",
       "      <td>62.290000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>50.530000</td>\n",
       "      <td>11.600000</td>\n",
       "      <td>52.070000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>43.110000</td>\n",
       "      <td>64.171250</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>61.214667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>122.885000</td>\n",
       "      <td>113.007500</td>\n",
       "      <td>111.715000</td>\n",
       "      <td>105.162500</td>\n",
       "      <td>105.990000</td>\n",
       "      <td>100.397500</td>\n",
       "      <td>86.230000</td>\n",
       "      <td>82.442500</td>\n",
       "      <td>69.337500</td>\n",
       "      <td>65.587500</td>\n",
       "      <td>72.430000</td>\n",
       "      <td>70.190000</td>\n",
       "      <td>59.417500</td>\n",
       "      <td>57.585000</td>\n",
       "      <td>89.386429</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>83.880000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>143.600000</td>\n",
       "      <td>133.760000</td>\n",
       "      <td>130.655000</td>\n",
       "      <td>123.175000</td>\n",
       "      <td>121.625000</td>\n",
       "      <td>116.180000</td>\n",
       "      <td>100.005000</td>\n",
       "      <td>95.555000</td>\n",
       "      <td>77.575000</td>\n",
       "      <td>74.680000</td>\n",
       "      <td>83.520000</td>\n",
       "      <td>80.160000</td>\n",
       "      <td>69.070000</td>\n",
       "      <td>66.995000</td>\n",
       "      <td>102.886230</td>\n",
       "      <td>5.000000</td>\n",
       "      <td>96.655000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>155.340000</td>\n",
       "      <td>152.392500</td>\n",
       "      <td>145.040000</td>\n",
       "      <td>141.250000</td>\n",
       "      <td>131.827500</td>\n",
       "      <td>128.477500</td>\n",
       "      <td>112.525000</td>\n",
       "      <td>109.602500</td>\n",
       "      <td>92.340000</td>\n",
       "      <td>86.982500</td>\n",
       "      <td>97.010000</td>\n",
       "      <td>92.535000</td>\n",
       "      <td>84.230000</td>\n",
       "      <td>80.227500</td>\n",
       "      <td>111.793036</td>\n",
       "      <td>5.000000</td>\n",
       "      <td>104.574333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>189.380000</td>\n",
       "      <td>189.380000</td>\n",
       "      <td>177.290000</td>\n",
       "      <td>177.330000</td>\n",
       "      <td>165.070000</td>\n",
       "      <td>165.070000</td>\n",
       "      <td>137.240000</td>\n",
       "      <td>137.250000</td>\n",
       "      <td>110.750000</td>\n",
       "      <td>110.750000</td>\n",
       "      <td>117.470000</td>\n",
       "      <td>117.470000</td>\n",
       "      <td>101.730000</td>\n",
       "      <td>101.730000</td>\n",
       "      <td>131.453333</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>116.106000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       Kolkata_Average_Price  Kolkata_Ref_Price  Bangalore_Average_Price  \\\n",
       "count             544.000000         544.000000               544.000000   \n",
       "mean              137.254890         131.644467               127.478327   \n",
       "std                23.646185          26.102421                23.124376   \n",
       "min                67.640000          64.790000                66.400000   \n",
       "25%               122.885000         113.007500               111.715000   \n",
       "50%               143.600000         133.760000               130.655000   \n",
       "75%               155.340000         152.392500               145.040000   \n",
       "max               189.380000         189.380000               177.290000   \n",
       "\n",
       "       Bangalore_Ref_Price  Cochin_Average_Price  Cochin_Ref_Price  \\\n",
       "count           544.000000            544.000000        544.000000   \n",
       "mean            121.630588            119.128640        113.863640   \n",
       "std              25.361527             19.036986         20.637354   \n",
       "min              55.650000             71.290000         57.020000   \n",
       "25%             105.162500            105.990000        100.397500   \n",
       "50%             123.175000            121.625000        116.180000   \n",
       "75%             141.250000            131.827500        128.477500   \n",
       "max             177.330000            165.070000        165.070000   \n",
       "\n",
       "       Darjeeling_Average_Price  Darjeeling_Ref_Price  \\\n",
       "count                544.000000            544.000000   \n",
       "mean                 100.817463             95.589173   \n",
       "std                   16.669939             18.052455   \n",
       "min                   62.290000              0.000000   \n",
       "25%                   86.230000             82.442500   \n",
       "50%                  100.005000             95.555000   \n",
       "75%                  112.525000            109.602500   \n",
       "max                  137.240000            137.250000   \n",
       "\n",
       "       Ernakulam_Average_Price  Ernakulam_Ref_Price  Siliguri_Average_Price  \\\n",
       "count               544.000000           544.000000              544.000000   \n",
       "mean                 79.787224            76.863364               84.819449   \n",
       "std                  14.671259            14.324043               15.564106   \n",
       "min                   0.000000            50.530000               11.600000   \n",
       "25%                  69.337500            65.587500               72.430000   \n",
       "50%                  77.575000            74.680000               83.520000   \n",
       "75%                  92.340000            86.982500               97.010000   \n",
       "max                 110.750000           110.750000              117.470000   \n",
       "\n",
       "       Siliguri_Ref_Price  Guwahati_Average_Price  Guwahati_Ref_Price  \\\n",
       "count          544.000000              544.000000          544.000000   \n",
       "mean            80.965404               71.446562           69.312445   \n",
       "std             15.003531               14.766510           14.153677   \n",
       "min             52.070000                0.000000           43.110000   \n",
       "25%             70.190000               59.417500           57.585000   \n",
       "50%             80.160000               69.070000           66.995000   \n",
       "75%             92.535000               84.230000           80.227500   \n",
       "max            117.470000              101.730000          101.730000   \n",
       "\n",
       "          Average     weekday         avg  \n",
       "count  544.000000  544.000000  544.000000  \n",
       "mean   100.660317    4.270221   94.324790  \n",
       "std     13.711767    1.546860   12.374570  \n",
       "min     64.171250    0.000000   61.214667  \n",
       "25%     89.386429    4.000000   83.880000  \n",
       "50%    102.886230    5.000000   96.655000  \n",
       "75%    111.793036    5.000000  104.574333  \n",
       "max    131.453333    6.000000  116.106000  "
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Separating predictor and target variables\n",
    "X, y = df.drop(['Average'], axis=1), df['Average']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Kolkata_Average_Price</th>\n",
       "      <th>Kolkata_Ref_Price</th>\n",
       "      <th>Bangalore_Average_Price</th>\n",
       "      <th>Bangalore_Ref_Price</th>\n",
       "      <th>Cochin_Average_Price</th>\n",
       "      <th>Cochin_Ref_Price</th>\n",
       "      <th>Darjeeling_Average_Price</th>\n",
       "      <th>Darjeeling_Ref_Price</th>\n",
       "      <th>Ernakulam_Average_Price</th>\n",
       "      <th>Ernakulam_Ref_Price</th>\n",
       "      <th>Siliguri_Average_Price</th>\n",
       "      <th>Siliguri_Ref_Price</th>\n",
       "      <th>Guwahati_Average_Price</th>\n",
       "      <th>Guwahati_Ref_Price</th>\n",
       "      <th>weekday</th>\n",
       "      <th>avg</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>WeekEnding_Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>03/01/09</th>\n",
       "      <td>99.01</td>\n",
       "      <td>79.79</td>\n",
       "      <td>87.48</td>\n",
       "      <td>76.19</td>\n",
       "      <td>84.02</td>\n",
       "      <td>70.07</td>\n",
       "      <td>81.66</td>\n",
       "      <td>57.83</td>\n",
       "      <td>68.94</td>\n",
       "      <td>51.67</td>\n",
       "      <td>70.74</td>\n",
       "      <td>53.88</td>\n",
       "      <td>65.55</td>\n",
       "      <td>46.75</td>\n",
       "      <td>6.0</td>\n",
       "      <td>66.638667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10/01/09</th>\n",
       "      <td>97.74</td>\n",
       "      <td>78.73</td>\n",
       "      <td>87.48</td>\n",
       "      <td>73.97</td>\n",
       "      <td>82.72</td>\n",
       "      <td>68.17</td>\n",
       "      <td>83.31</td>\n",
       "      <td>58.02</td>\n",
       "      <td>67.24</td>\n",
       "      <td>52.23</td>\n",
       "      <td>70.47</td>\n",
       "      <td>53.39</td>\n",
       "      <td>67.39</td>\n",
       "      <td>46.84</td>\n",
       "      <td>3.0</td>\n",
       "      <td>66.046667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17/01/09</th>\n",
       "      <td>95.95</td>\n",
       "      <td>71.01</td>\n",
       "      <td>87.66</td>\n",
       "      <td>71.01</td>\n",
       "      <td>80.58</td>\n",
       "      <td>67.16</td>\n",
       "      <td>82.25</td>\n",
       "      <td>57.49</td>\n",
       "      <td>69.64</td>\n",
       "      <td>52.48</td>\n",
       "      <td>71.66</td>\n",
       "      <td>53.18</td>\n",
       "      <td>69.51</td>\n",
       "      <td>48.04</td>\n",
       "      <td>5.0</td>\n",
       "      <td>65.508000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24/01/09</th>\n",
       "      <td>94.14</td>\n",
       "      <td>73.38</td>\n",
       "      <td>85.69</td>\n",
       "      <td>65.66</td>\n",
       "      <td>80.58</td>\n",
       "      <td>65.57</td>\n",
       "      <td>80.87</td>\n",
       "      <td>54.59</td>\n",
       "      <td>69.64</td>\n",
       "      <td>53.43</td>\n",
       "      <td>71.12</td>\n",
       "      <td>52.07</td>\n",
       "      <td>69.14</td>\n",
       "      <td>48.50</td>\n",
       "      <td>5.0</td>\n",
       "      <td>64.625333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31/01/09</th>\n",
       "      <td>91.45</td>\n",
       "      <td>70.39</td>\n",
       "      <td>85.69</td>\n",
       "      <td>64.99</td>\n",
       "      <td>79.27</td>\n",
       "      <td>62.09</td>\n",
       "      <td>80.76</td>\n",
       "      <td>57.06</td>\n",
       "      <td>69.65</td>\n",
       "      <td>53.38</td>\n",
       "      <td>72.30</td>\n",
       "      <td>52.50</td>\n",
       "      <td>69.39</td>\n",
       "      <td>50.33</td>\n",
       "      <td>5.0</td>\n",
       "      <td>64.283333</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                 Kolkata_Average_Price  Kolkata_Ref_Price  \\\n",
       "WeekEnding_Date                                             \n",
       "03/01/09                         99.01              79.79   \n",
       "10/01/09                         97.74              78.73   \n",
       "17/01/09                         95.95              71.01   \n",
       "24/01/09                         94.14              73.38   \n",
       "31/01/09                         91.45              70.39   \n",
       "\n",
       "                 Bangalore_Average_Price  Bangalore_Ref_Price  \\\n",
       "WeekEnding_Date                                                 \n",
       "03/01/09                           87.48                76.19   \n",
       "10/01/09                           87.48                73.97   \n",
       "17/01/09                           87.66                71.01   \n",
       "24/01/09                           85.69                65.66   \n",
       "31/01/09                           85.69                64.99   \n",
       "\n",
       "                 Cochin_Average_Price  Cochin_Ref_Price  \\\n",
       "WeekEnding_Date                                           \n",
       "03/01/09                        84.02             70.07   \n",
       "10/01/09                        82.72             68.17   \n",
       "17/01/09                        80.58             67.16   \n",
       "24/01/09                        80.58             65.57   \n",
       "31/01/09                        79.27             62.09   \n",
       "\n",
       "                 Darjeeling_Average_Price  Darjeeling_Ref_Price  \\\n",
       "WeekEnding_Date                                                   \n",
       "03/01/09                            81.66                 57.83   \n",
       "10/01/09                            83.31                 58.02   \n",
       "17/01/09                            82.25                 57.49   \n",
       "24/01/09                            80.87                 54.59   \n",
       "31/01/09                            80.76                 57.06   \n",
       "\n",
       "                 Ernakulam_Average_Price  Ernakulam_Ref_Price  \\\n",
       "WeekEnding_Date                                                 \n",
       "03/01/09                           68.94                51.67   \n",
       "10/01/09                           67.24                52.23   \n",
       "17/01/09                           69.64                52.48   \n",
       "24/01/09                           69.64                53.43   \n",
       "31/01/09                           69.65                53.38   \n",
       "\n",
       "                 Siliguri_Average_Price  Siliguri_Ref_Price  \\\n",
       "WeekEnding_Date                                               \n",
       "03/01/09                          70.74               53.88   \n",
       "10/01/09                          70.47               53.39   \n",
       "17/01/09                          71.66               53.18   \n",
       "24/01/09                          71.12               52.07   \n",
       "31/01/09                          72.30               52.50   \n",
       "\n",
       "                 Guwahati_Average_Price  Guwahati_Ref_Price  weekday  \\\n",
       "WeekEnding_Date                                                        \n",
       "03/01/09                          65.55               46.75      6.0   \n",
       "10/01/09                          67.39               46.84      3.0   \n",
       "17/01/09                          69.51               48.04      5.0   \n",
       "24/01/09                          69.14               48.50      5.0   \n",
       "31/01/09                          69.39               50.33      5.0   \n",
       "\n",
       "                       avg  \n",
       "WeekEnding_Date             \n",
       "03/01/09         66.638667  \n",
       "10/01/09         66.046667  \n",
       "17/01/09         65.508000  \n",
       "24/01/09         64.625333  \n",
       "31/01/09         64.283333  "
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## LightGBM  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "def lgb_model():\n",
    "    scores = []\n",
    "    splits=20\n",
    "    \n",
    "    oof=np.zeros(len(X))\n",
    "    test_pred =np.zeros(len(test))\n",
    "    #holdout_pred = np.zeros(len(test_X))\n",
    "    \n",
    "    print('***********************************************************')\n",
    "    kf = KFold(n_splits=splits, shuffle=False)\n",
    "    for fold, (train_index, test_index) in enumerate(kf.split(X, y)):\n",
    "        \n",
    "        X_train, X_val = X.iloc[train_index], X.iloc[test_index]\n",
    "        y_train, y_val = y.iloc[train_index], y.iloc[test_index]\n",
    "        \n",
    "        model = lgb.LGBMRegressor(n_estimators=10000, learning_rate=0.06, random_state=100, max_depth=10, num_leaves=90)#, colsample_bytree=0.8)\n",
    "\n",
    "        model.fit(X_train, y_train, eval_set=[(X_val, y_val)], early_stopping_rounds=300, verbose=False)\n",
    "        pred = model.predict(X_val)                                               \n",
    "        oof[test_index] = pred\n",
    "        score = np.sqrt(mean_squared_error(y_val, pred))\n",
    "        \n",
    "        print(f'rmse score for fold {fold} is {score}')\n",
    "        scores.append(score)\n",
    "        \n",
    "        test_pred += model.predict(test)\n",
    "            \n",
    "    print(f'\\nAvg score for all folds is {np.sum(scores)/splits}')\n",
    "    \n",
    "    print('***********************************************************')\n",
    "    print(f'\\nOOF Score after completing folds is {np.sqrt(mean_squared_error(y, oof))}')\n",
    "    test_df = pd.DataFrame(test_pred, columns=['Average'])\n",
    "    test_df = test_df/splits\n",
    "    #print(f'\\nRMSE Score for HOLDOUT Data is {np.sqrt(mean_squared_log_error(np.expm1(test_y), np.expm1(holdout_pred/8)))}')\n",
    "    return test_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "***********************************************************\n",
      "rmse score for fold 0 is 3.7077418004177902\n",
      "rmse score for fold 1 is 2.204992093003887\n",
      "rmse score for fold 2 is 1.6149520792580836\n",
      "rmse score for fold 3 is 2.176307736411075\n",
      "rmse score for fold 4 is 2.2903001521054747\n",
      "rmse score for fold 5 is 4.872771557062859\n",
      "rmse score for fold 6 is 2.206690383100683\n",
      "rmse score for fold 7 is 5.033071680449239\n",
      "rmse score for fold 8 is 3.1179431627630954\n",
      "rmse score for fold 9 is 5.901846479480736\n",
      "rmse score for fold 10 is 1.5950511840094912\n",
      "rmse score for fold 11 is 5.805880429818514\n",
      "rmse score for fold 12 is 1.765825763617948\n",
      "rmse score for fold 13 is 4.4165992561761005\n",
      "rmse score for fold 14 is 2.338170042155939\n",
      "rmse score for fold 15 is 1.7772528109768972\n",
      "rmse score for fold 16 is 2.8112437737511393\n",
      "rmse score for fold 17 is 2.1729179223874073\n",
      "rmse score for fold 18 is 1.9192807742518456\n",
      "rmse score for fold 19 is 2.2719924899879347\n",
      "\n",
      "Avg score for all folds is 3.000041578559307\n",
      "***********************************************************\n",
      "\n",
      "OOF Score after completing folds is 3.3016428516854543\n"
     ]
    }
   ],
   "source": [
    "lgb_ = lgb_model()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## XGBoost "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "def xgb_model():\n",
    "    scores = []\n",
    "    splits=20\n",
    "    \n",
    "    oof=np.zeros(len(X))\n",
    "    test_pred =np.zeros(len(test))\n",
    "    #holdout_pred = np.zeros(len(test_X))\n",
    "    \n",
    "    print('***********************************************************')\n",
    "    kf = KFold(n_splits=splits, shuffle=False)\n",
    "    for fold, (train_index, test_index) in enumerate(kf.split(X, y)):\n",
    "        \n",
    "        X_train, X_val = X.iloc[train_index], X.iloc[test_index]\n",
    "        y_train, y_val = y.iloc[train_index], y.iloc[test_index]\n",
    "        \n",
    "        model = xgb.XGBRegressor(n_estimators=10000, learning_rate=0.06, random_state=100, max_depth=10)\n",
    "        model.fit(X_train, y_train, eval_set=[(X_val, y_val)], early_stopping_rounds=30, verbose=False)\n",
    "        pred = model.predict(X_val)                                              \n",
    "        oof[test_index] = pred\n",
    "        score = np.sqrt(mean_squared_error(y_val, pred))\n",
    "        \n",
    "        print(f'rmse score for fold {fold} is {score}')\n",
    "        scores.append(score)\n",
    "\n",
    "        test_pred += model.predict(test)\n",
    "\n",
    "    print(f'\\nAvg score for all folds is {np.sum(scores)/splits}')\n",
    "    \n",
    "    print('***********************************************************')\n",
    "    print(f'\\nOOF Score after completing folds is {np.sqrt(mean_squared_error(y, oof))}')\n",
    "    \n",
    "    test_df = pd.DataFrame(test_pred, columns=['Average'])\n",
    "    test_df = test_df/splits\n",
    "    #print(f'\\nRMSE Score for HOLDOUT Data is {np.sqrt(mean_squared_log_error(np.expm1(test_y), np.expm1(holdout_pred/8)))}')\n",
    "    return test_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "***********************************************************\n",
      "[02:02:55] WARNING: src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror.\n",
      "rmse score for fold 0 is 1.782050993723448\n",
      "[02:02:56] WARNING: src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror.\n",
      "rmse score for fold 1 is 2.153147753238721\n",
      "[02:02:58] WARNING: src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror.\n",
      "rmse score for fold 2 is 1.9340701479985536\n",
      "[02:03:01] WARNING: src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror.\n",
      "rmse score for fold 3 is 2.6611497214771274\n",
      "[02:03:02] WARNING: src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror.\n",
      "rmse score for fold 4 is 1.74371058198841\n",
      "[02:03:05] WARNING: src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror.\n",
      "rmse score for fold 5 is 5.148457478283427\n",
      "[02:03:06] WARNING: src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror.\n",
      "rmse score for fold 6 is 1.9059715301582343\n",
      "[02:03:07] WARNING: src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror.\n",
      "rmse score for fold 7 is 5.070603063087166\n",
      "[02:03:08] WARNING: src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror.\n",
      "rmse score for fold 8 is 3.0465399617331133\n",
      "[02:03:09] WARNING: src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror.\n",
      "rmse score for fold 9 is 6.065809180510796\n",
      "[02:03:09] WARNING: src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror.\n",
      "rmse score for fold 10 is 2.3997936140967413\n",
      "[02:03:11] WARNING: src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror.\n",
      "rmse score for fold 11 is 6.33164329646534\n",
      "[02:03:12] WARNING: src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror.\n",
      "rmse score for fold 12 is 1.9767087124999974\n",
      "[02:03:13] WARNING: src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror.\n",
      "rmse score for fold 13 is 4.126280888674146\n",
      "[02:03:14] WARNING: src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror.\n",
      "rmse score for fold 14 is 2.715854968949943\n",
      "[02:03:15] WARNING: src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror.\n",
      "rmse score for fold 15 is 2.0428405768132993\n",
      "[02:03:17] WARNING: src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror.\n",
      "rmse score for fold 16 is 2.8536054312570416\n",
      "[02:03:18] WARNING: src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror.\n",
      "rmse score for fold 17 is 2.983983526158258\n",
      "[02:03:19] WARNING: src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror.\n",
      "rmse score for fold 18 is 1.7485033101303544\n",
      "[02:03:19] WARNING: src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror.\n",
      "rmse score for fold 19 is 1.9602369968318678\n",
      "\n",
      "Avg score for all folds is 3.032548086703799\n",
      "***********************************************************\n",
      "\n",
      "OOF Score after completing folds is 3.353378880387709\n"
     ]
    }
   ],
   "source": [
    "xgb_ = xgb_model()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Weighted Average of LightGBM and XGBoost based predictions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "sub = (0.7*lgb_) + (0.3*xgb_)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "####   Saving CSV file"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "sub.to_csv(r'C:\\MachineHack\\Participant_Data_Tea_Story\\submissions\\sub_pred.csv', index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Average</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>119.618446</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>119.592254</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>119.562632</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>119.409095</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>119.396210</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      Average\n",
       "0  119.618446\n",
       "1  119.592254\n",
       "2  119.562632\n",
       "3  119.409095\n",
       "4  119.396210"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sub.head()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
